#include "timer.h"

volatile uint32_t glo_100ms=0;

void Init_Timer2(void)
{
  TIM2_DeInit();
  TIM2_TimeBaseInit(TIM2_PRESCALER_256, 250-1);         //cau hinh bo chia cho TIMER2 chay 4ms
  TIM2_ClearFlag(TIM2_FLAG_UPDATE);                     // Xoa co ngat timer2
  TIM2_ITConfig(TIM2_IT_UPDATE,ENABLE);                 // Cho phep ngat khi tran sau khi dem 487 cycle
  TIM2_Cmd(ENABLE);
}

void Init_Timer4(void)
{
  TIM4_DeInit();
  TIM4_TimeBaseInit(TIM4_PRESCALER_128, 250-1);//2ms
  TIM4_ClearFlag(TIM4_FLAG_UPDATE);
  TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);
//  TIM4_Cmd(ENABLE);
}

uint32_t Get100millis(void)
{
  return glo_100ms;
}
